c	Created: Wednesday, August 14, 1991 at 12:11 PM
c	 Components.f
c	 FORTRAN Interface to the Macintosh Libraries	

c	 Copyright Apple Computer, Inc. 1990 - 1991
c	 All rights reserved

!!IFC (.NOT. UsingIncludes)
!!I zeroinc.f	
!!ENDC

!!IFC (.NOT. GOTTypes)
!!I Types.f
!!ENDC

!!IFC NOT GOTCOMPONENTS
!!SETC GOTCOMPONENTS = TRUE
	Character*4 gestaltComponentMgr
	Parameter (gestaltComponentMgr = 'cpnt')
	
	Integer*2 kAnyComponentType 
	Integer*2 kAnyComponentSubType 
	Integer*2 kAnyComponentManufacturer 
	Integer*2 kAnyComponentFlagsMask 
	Parameter (kAnyComponentType =			0)
	Parameter (kAnyComponentSubType = 		0)
	Parameter (kAnyComponentManufacturer =	0)
	Parameter (kAnyComponentFlagsMask =	0)
	
	Integer*4 cmpWantsRegisterMessage
	Parameter (cmpWantsRegisterMessage = $80000000)
	
	
	Structure /ComponentDescription/
	 Record /OSType/  componentType			! A unique 4-byte code indentifying the command set 
	 Record /OSType/  componentSubType		! Particular flavor of this instance 
	 Record /OSType/  componentManufacturer	! Vendor indentification 
	 Integer*4 componentFlags				! 8 each for Component,Type,SubType,Manuf/revision 
	 Integer*4 componentFlagsMask			! Mask for specifying which flags to consider in search, zero during registration 
	End Structure
	
	Structure /ResourceSpec/
	 Record /OSType/  resType			! 4-byte code  
	 Integer*2 resId	    
	End Structure
	
	Structure /ComponentResource/
	 Record /ComponentDescription/ cd		! Registration parameters 
	 Record /ResourceSpec/ component		! resource where Component code is found 
	 Record /ResourceSpec/ componentName	! name string resource 
	 Record /ResourceSpec/ componentInfo	! info string resource 
	 Record /ResourceSpec/ componentIcon	! icon resource 
	End Structure

	Structure /ComponentResourcePtr/
		Pointer /ComponentResource/ p
	End Structure

	Structure /ComponentResourceHandle/
		Pointer /ComponentResourcePtr/ h
	End Structure

	! Structure received by Component: 
	Structure /ComponentParameters/
	 byte flags				! call sync/async, modifiers: deferred, immed, etc 
	 byte paramSize			! size in bytes of actual parameters passed to this call 
	 Integer*2 what			! routine selector, negative for Component management calls 
	 Integer*4 params(0:0)	! actual parameters for the indicated routine 
	End Structure
	
	Structure /ComponentRecord/
	 Integer*4 data(0:0)
	End Structure

	Structure /Component/
		Pointer /ComponentRecord/ p
	End Structure
	
	Structure /ComponentInstanceRecord/
	 Integer*4 data(0:0)
	End Structure

	Structure /ComponentInstance/
		Pointer /ComponentInstanceRecord/ p
	End Structure	
	
	
c	ComponentResult = Integer*4
c	ComponentRoutine = Integer*4
c	ComponentFunction = Integer*4
	
	Integer*2 kComponentOpenSelect 
	Integer*2 kComponentCloseSelect 
	Integer*2 kComponentCanDoSelect 
	Integer*2 kComponentVersionSelect 
	Integer*2 kComponentRegisterSelect 
	Integer*2 kComponentTargetSelect 
	Parameter (kComponentOpenSelect = -1)			! ComponentInstance for this open 
	Parameter (kComponentCloseSelect = -2)			! ComponentInstance for this close 
	Parameter (kComponentCanDoSelect = -3	)		! selector # being queried 
	Parameter (kComponentVersionSelect = -4	)		! no params 
	Parameter (kComponentRegisterSelect = -5)		! no params 
	Parameter (kComponentTargetSelect = -6	)		! ComponentInstance for top of call chain 
	
	
	! Set Default Component flags 
	Integer*2 defaultComponentIdentical 
	Integer*2 defaultComponentAnyFlags 
	Integer*2 defaultComponentAnyManufacturer 
	Integer*2 defaultComponentAnySubType 
	Integer*2 defaultComponentAnyFlagsAnyManufacturer 
	Integer*2 defaultCompAnyFlagsAnyManufacturerAnySubType 
	Parameter (defaultComponentIdentical = 0)
	Parameter (defaultComponentAnyFlags = 1)
	Parameter (defaultComponentAnyManufacturer = 2)
	Parameter (defaultComponentAnySubType = 4)
	Parameter (defaultComponentAnyFlagsAnyManufacturer = defaultComponentAnyFlags+
	1	defaultComponentAnyManufacturer)
	Parameter (defaultCompAnyFlagsAnyManufacturerAnySubType = 
	1	defaultComponentAnyFlags+defaultComponentAnyManufacturer+
	2	defaultComponentAnySubType)
	
	! errors from component manager & components 
	Integer*2 invalidComponentID 
	Integer*2 validInstancesExist 
	Integer*2 componentNotCaptured 
	Integer*2 componentDontRegister 
	Parameter (invalidComponentID = -3000)
	Parameter (validInstancesExist = -3001)
	Parameter (componentNotCaptured = -3002)
	Parameter (componentDontRegister = -3003)
	
	Integer*4 badComponentInstance 
	Integer*4 badComponentSelector 
	Parameter (badComponentInstance = $80008001)
	Parameter (badComponentSelector = $80008002)
	
!!ENDC ! GotComponents 
	